package cn.tannn.surenessdemo.user.entity;

import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import org.hibernate.Hibernate;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Index;
import javax.persistence.Table;
import java.util.Objects;

/**
 * 前端路由表 （前端页面目录菜单）
 * @date  2021-06-08 09:45:21
 * @author tn
 * @version 1
 */
@Entity
@Table (name ="auth_route", indexes = {
				@Index(name = "name_parent_index", columnList = "name,parentCode", unique = true),
		})
@org.hibernate.annotations.Table(appliesTo = "auth_route",comment = "前端路由表 （前端页面目录菜单）")
@Getter
@Setter
@ToString
@RequiredArgsConstructor
@DynamicUpdate
@DynamicInsert
public class AuthRoute extends CommonBean<AuthRoute> {

	/**
	 * 路由编码
	 */
	@Column(columnDefinition = " varchar(50) not null comment '路由编码' ")
	private String code;

	/**
	 * 路由名称，同级名称唯一
	 */
	@Column(columnDefinition = " varchar(50)  not null comment '路由名称，同级名称唯一' " )
	private String name;

	/**
	 * 路由类型（0、节点；1、功能；2、按钮）
	 */
	@Column(columnDefinition = " int(11)  comment '路由类型（0、节点；1、功能；2、按钮）' " )
	private Integer routeType;

	/**
	 * 路由地址
	 */
	@Column(columnDefinition = " varchar(200)  comment '路由地址' " )
	private String route;

	/**
	 * 父级Code
	 */
	@Column(columnDefinition = "varchar(55) default 0 comment '父级Code' " )
	private String parentCode;

	/**
	 * 排序，数字越小排在越前面
	 */
	@Column(columnDefinition = " int(11)  default 0  comment '排序，数字越小排在越前面' " )
	private Integer sortNumber;

	/**
	 * 图标
	 */
	@Column(columnDefinition = " varchar(200) comment '图标' " )
	private String icon;


	/**
	 * 节点状态（0、禁用；1、启用）默认启用
	 */
	@Column(columnDefinition = "int(11)  default 1  comment '节点状态（0、禁用；1、启用）默认启用' " )
	private Integer status;

	/**
	 * 前端组件
	 */
	@Column(columnDefinition = " varchar(255) not null comment '前端组件' " )
	private String component;

	/**
	 * 前端组件名称
	 */
	@Column(columnDefinition = " varchar(255) not null comment '前端组件名称' " )
	private String componentName;

	@Override
	public boolean equals(Object o) {
		if (this == o) {
			return true;
		}
		if (o == null || Hibernate.getClass(this) != Hibernate.getClass(o)) {
			return false;
		}
		AuthRoute authRoute = (AuthRoute) o;
		return getId() != null && Objects.equals(getId(), authRoute.getId());
	}

	@Override
	public int hashCode() {
		return getClass().hashCode();
	}
}
